package com.shzg.im.model;

import java.sql.Date;
import java.util.Set;

import org.springframework.util.StringUtils;

public class User {

    private String login_id;

    private String password = "";

    private String nick_name = "";

    private String avatar = "";

    private String description = "";

    private Date create_time;

    private Set<Category> categorySet;

    public String getLogin_id() {
        return login_id;
    }

    public void setLogin_id(String login_id) {
        this.login_id = login_id;
    }

    public String getNick_name() {
        return nick_name;
    }

    public void setNick_name(String nick_name) {
        this.nick_name = nick_name;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAvatar() {
        if (StringUtils.isEmpty(avatar)) {
            return "images/head/q1.jpg";
        }
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Category> getCategorySet() {
        return categorySet;
    }

    public void setCategorySet(Set<Category> categorySet) {
        this.categorySet = categorySet;
    }

    @Override
    public String toString() {
        return String.format("User [loginId=%s, password=%s, nickName=%s, avatar=%s, description=%s, categorySet=%s]",
                login_id, password, nick_name, avatar, description, categorySet);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getLogin_id() == null) ? 0 : getLogin_id().hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        User other = (User) obj;
        if (getLogin_id() == null) {
            if (other.getLogin_id() != null)
                return false;
        } else if (!getLogin_id().equals(other.getLogin_id()))
            return false;
        return true;
    }

}
